package com.example.qt.ptplatform.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.qt.ptplatform.entity.UserAssessment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserAssessmentMapper extends BaseMapper<UserAssessment> {
    // 查询用户的所有考核记录
    @Select("SELECT * FROM user_assessments WHERE user_id = #{userId} ORDER BY assessment_date DESC")
    List<UserAssessment> selectAssessmentHistoryByUserId(Integer userId);

    // 查询用户的最新考核结果
    @Select("SELECT * FROM user_assessments WHERE user_id = #{userId} ORDER BY assessment_date DESC LIMIT 1")
    UserAssessment selectLatestAssessmentByUserId(Integer userId);

    // 获取用户最近三次考核记录
    @Select("SELECT * FROM user_assessments WHERE user_id = #{userId} ORDER BY assessment_date DESC LIMIT 3")
    List<UserAssessment> getRecentAssessments(@Param("userId") Integer userId, int limit);
}
